package com.ruoyi.web.controller.system;

import com.ruoyi.system.domain.User;
import com.ruoyi.system.service.impl.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class HelloController {
    @Autowired
    private UserServiceImpl userService;

    @GetMapping("/hello")
    public List<User> hello()
    {
        return userService.selectAllUser();
    }

    //新增
    @PostMapping("/hello/insert")                          //Post
    public String helloPost(String name ,int age,int sex)
    {
        userService.insertUser(name,age,sex);
        return "add name: "+name + ", age= "+age + ",sex=" + sex;
    }

    @PutMapping("/hello/update")                           //Put
    public String helloPut(int id,String name,int age,int sex)
    {
        userService.updateUsers(id,name,age,sex);
        return "update name:"+ name + ", age=" + age + ",sex=" + sex;

    }

    @DeleteMapping("/hello/{name}")                         //Delete
    public  String helloDel(@PathVariable String name)
    {
        userService.deleteName(name);
        return "delete name: "+name;
    }
}
